#ifndef __HTTPCONNECTION_H__
#define __HTTPCONNECTION_H__
#include <http/mhttptransactioncallback.h>
#include <http/rhttpsession.h>
#include <f32file.h>
#include "RegExpUtil.h"
typedef enum tag_THttpResult
{
    EHttpOK,
    EHttpUriError,
    EHttpNoConn,
    EHttpNoFile,
    EHttpServerError,
    EHttpRegularError
}THttpResult;
class MHttpRevObserver
{public:
    virtual void HttpResponse(THttpResult result,RegExpResultLine *line)=0;
};

class CHttpConnection:public MHTTPTransactionCallback
{
public:
    CHttpConnection(RFs &aRfs,const TDesC &aFileName);
    ~CHttpConnection();
    void HttpRequest(RHTTPSession *aSession,const TDesC8 &aUri,TInt aMethod,const TDesC8 &aData,MHttpRevObserver *aObserver);
    void Cancel();
private:
    void AppendCookieHead(RHTTPHeaders &head);
    HBufC* GetHost(const TDesC8 &aUri);
private:
    MHttpRevObserver *iObserver;
    RHTTPTransaction iTransaction;
    TInt iStatusCode;
    RFs &iRfs;
    CBufFlat *iBodyData;
    const TDesC &iFileName;
    HBufC* iHostUrl;
public:
    void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
    TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
};

#endif
